package cn.edu.abtu.controller;

import cn.edu.abtu.entity.EduTeacher;
import cn.edu.abtu.entity.vo.TeacherQuery;
import cn.edu.abtu.service.EduTeacherService;
import cn.edu.abtu.vo.ResponseData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@CrossOrigin
@RequestMapping("/eduservice/teacher")
public class EduTeacherController {


    @Autowired
    private EduTeacherService eduTeacherService;

    @PostMapping("/add")
    public ResponseData add(@RequestBody EduTeacher eduTeacher) {
        return eduTeacherService.add(eduTeacher);
    }

    @DeleteMapping("/delete")
    public ResponseData delete(String teacherId) {
        return eduTeacherService.delete(teacherId);
    }

    @PostMapping("/page")
    public ResponseData page(@RequestParam("pageNum") Integer pageNum,
                             @RequestParam("pageSize") Integer pageSize,
                             @RequestBody(required = false) TeacherQuery teacherQuery) {
        return eduTeacherService.page(pageNum, pageSize, teacherQuery);
    }

    @GetMapping("/list")
    public ResponseData list(){
        return eduTeacherService.list();
    }

    @GetMapping("queryById/{teacherId}")
    public ResponseData queryById(@PathVariable String teacherId) {
        return eduTeacherService.queryById(teacherId);
    }

    @PutMapping("/update")
    public ResponseData update(@RequestBody EduTeacher eduTeacher) {
        return eduTeacherService.update(eduTeacher);
    }

}

